﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>UpdateSysUser</title>
      <link rel="stylesheet" type="text/css" href="../../Content/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="../../Content/themes/icon.css" />
    <link rel="stylesheet" type="text/css" href="../../Content/themes/default/form.css" />
    <script type="text/javascript" language="javascript" src=' <%=Url.Content("~/Scripts/jquery-1.4.4.min.js") %>'></script>
    <script type="text/javascript" language="javascript" src='<%=Url.Content("~/Scripts/jquery.easyui.min.js") %>'></script>
    <script type="text/javascript" src='<%=Url.Content("~/Scripts/jquery.form.js") %>'></script>
    <script type="text/javascript" language="javascript" src=' <%=Url.Content("~/Scripts/jquery.validate.js") %>'></script>
    <script type="text/javascript" language="javascript">
        $(function() {          
            var userForm = $("#userForm");
            var tbs = userForm.children("table").children("tbody").children("tr").children("td");
            userForm.validate({
                rules: {
//                oldpwd: {
//                        required: true,
//                        minlength: 6
//                    },
//                    userpwd: {
//                        required: true,
//                        minlength: 6
//                    },
                    repwd: {
                    equalTo: "#userpwd"
                    }
                }
            });
        });
        function update() {
            var userForm = $("#userForm");
            userForm.children("#myerro").remove();
            if (userForm.validate().form()) {
                var tbs = userForm.children("table").children("tbody").children("tr").children("td");
                var username = tbs.children("#username").val();
                var id = tbs.children("#id").val();
                var userpwd = tbs.children("#userpwd").val();
                var oldpwd = tbs.children("#oldpwd").val();
                var role = tbs.children("#ddlrole").val();
                var state = 1;
                if (tbs.children("#states_yes").attr("checked") == false) {
                    state = 0;
                 }
                 $.ajax({
                     type: "post",
                     url: "UpdateSysUser",
                     data: {
                         username: username,
                         userpwd: userpwd,
                         oldpwd: oldpwd,
                         role: role,
                         state: state,
                         id: id
                     },
                     dataType: 'text',
                     success: function(data) {
                     if (data != "1"){
                             userForm.append("<div id='myerro'><p>"+data+"</p></div>");
                     }else{
                        alert("更新成功！");
                        }
                     },
                     error: function(data) {
                     userForm.append("<div id='myerro'><p>" + data + "</p></div>");
                     }
                 });
            }
        }    
    </script>
</head>
<body>
    <div id="main_body">
        <form id="userForm" runat="server"  >
        <table class="formTable">
            <thead>
                <tr>
                    <td class="headlf">
                        修改系统用户
                    </td>
                    <td class="headrh">
                        <a class="ce" href="javascript:void(0)" onclick="mytoggle(this)">收起</a>
                    </td>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td class="label">
                        用户名：
                    </td>
                    <td>
                      <input type="text"  readonly="readonly" id="username" name="username"  value='<%= ViewData["username"].ToString() %>' />
                      <input type="text" visible="false" style=" display:none" id="id" name="id" value='<%= ViewData["id"].ToString() %>' />
                    </td>
                </tr>
                <tr>
                    <td class="label">
                        旧密码：
                    </td>
                    <td>
                        <input type="password" id="oldpwd" name="oldpwd" />
                    </td>
                </tr>
                <tr>
                    <td class="label">
                        新密码：
                    </td>
                    <td>
                        <input type="password" id="userpwd" name="userPwd" />
                    </td>
                </tr>
                <tr>
                    <td class="label">
                       确认密码：
                    </td>
                    <td>
                        <input type="password" id="repwd" name="repwd" />
                    </td>
                </tr>
                  <tr>
                    <td class="label">
                       用户角色：
                    </td>
                    <td>
                      <%= Html.DropDownList("ddlrole")%>    
                    </td>
                </tr>
                 <tr>
                    <td class="label">
                       用户状态：    
                    </td>
                    <td> 
                    启用:<%=ViewData["chk1"]%> 
                    锁定:<%=ViewData["chk2"]%>                      
                    </td>
                </tr>
                <tr>
                    <td class="label" style="text-align: left; padding-left: 250px;" colspan="2">                     
                        <input type="button"  onclick="update()" value="确认" />
                    </td>
                </tr>
            </tbody>
        </table>
        
        </form> 
    </div>
</body>
</html>
